﻿using System;
namespace myapp_common
{
    public class ResultValueObject<T>
    {
        public enum ResultCodes
        {
            COMMON = 200,
            ERROR = 500
        }

        public bool _success { get; set; } = false;
        public ResultCodes _code { get; set; } = ResultCodes.COMMON;
        public T _message { get; set; }

        public ResultValueObject(bool success, ResultCodes code, T message)
        {
            _success = success;
            _code = code;
            _message = message;
        }

        public ResultValueObject(bool success, T message)
        {
            _success = success;
            _message = message;
        }
        public ResultValueObject(bool success, ResultCodes code)
        {
            _success = success;
            _code = code;
        }
        public static ResultValueObject<T> success(T message)
        {
            return new ResultValueObject<T>(true, message);
        }

        public static ResultValueObject<T> fail(T message)
        {
            return new ResultValueObject<T>(false, ResultCodes.ERROR, message);
        }
        public static ResultValueObject<T> fail()
        {
            return new ResultValueObject<T>(false, ResultCodes.ERROR);
        }
        public static ResultValueObject<T> message(bool success, ResultCodes code, T message)
        {
            return new ResultValueObject<T>(success, code, message);
        }
    }
}
